package com.hgy.service.impl;

import com.github.pagehelper.PageHelper;
import com.hgy.dao.OrderDao;
import com.hgy.entity.Order;
import com.hgy.service.OrderService;
import com.hgy.vo.VOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author : ang
 * @Program: carSystem
 * @Title : OrderServiceImpl
 * @Date : 2020-08-28 10:37
 **/
@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    private OrderDao orderDao;

    @Override
    public void addOrder(Integer uid, Integer cid, Integer getid, Integer backid, String oprices) {
        String status = "已预定";
        double oprice = Double.parseDouble(oprices);
        Order order = new Order();
        order.setUid(uid);
        order.setCid(cid);
        order.setGetid(getid);
        order.setBackid(backid);
        order.setOprice(oprice);
        order.setStatus(status);
        orderDao.addOrder(order);
    }

    @Override
    public List<VOrder> selectAll(Integer uid,Integer page) {
        PageHelper.startPage(page,5);
        List<VOrder> list = orderDao.selectAll(uid);
        return list;
    }

    @Override
    public void deleteOrder(Integer id) {
        orderDao.deleteOrder(id);
    }
}
